#include "MeshRenderer.h"
#include "Transform.h"
#include "GameObject.h"
#include "Camera.h"
#include <glm/mat4x4.hpp>

namespace DYEngine
{
	MeshRenderer::MeshRenderer(): Renderer(), mMesh(nullptr)
	{

	}

	MeshRenderer::~MeshRenderer()
	{

	}

	bool MeshRenderer::IsSkinned()
	{
		return false;
	}

	void MeshRenderer::Draw()
	{
		Transform* transform = mGameObject->GetTransform();
		glm::mat4 vpMat = Camera::GetMainCamera()->GetVPMatrix();
		glm::mat4 mMat = transform->GetMatrix();
		mMaterial->SetMat4("mMatrix", mMat);
		mMaterial->SetMat4("vpMatrix", vpMat);
		mMaterial->Setup();
		mMesh->Draw();
	}

	void MeshRenderer::Destroy()
	{
		mMesh = nullptr;
	}
}
